@echo off
chcp 936 >nul
echo ========================================
echo    测试Nacos配置修改
echo ========================================
echo.

:: 设置项目根目录
set PROJECT_ROOT=F:\shopping
echo 项目根目录: %PROJECT_ROOT%

:: 设置Nacos服务器地址
set NACOS_SERVER_ADDR=192.168.5.111:8848
set NACOS_GRPC_ADDR=192.168.5.111:9848
echo Nacos服务器地址: %NACOS_SERVER_ADDR%

echo.
echo 正在编译并启动单个服务测试...
echo.

:: 编译auth-service
echo 编译auth-service...
cd %PROJECT_ROOT%\auth-service
call mvn clean package -DskipTests -q
if %ERRORLEVEL% NEQ 0 (
    echo 错误: auth-service编译失败
    pause
    exit /b 1
)
echo auth-service编译成功

echo.
echo 启动auth-service测试...
echo.
echo 注意: 观察启动日志中Nacos连接地址是否为 %NACOS_SERVER_ADDR%
echo.
echo 按任意键启动服务...
pause >nul

:: 启动auth-service
start "auth-service-test" cmd /k "chcp 65001 >nul && set NACOS_SERVER_ADDR=%NACOS_SERVER_ADDR% && set NACOS_GRPC_ADDR=%NACOS_GRPC_ADDR% && cd /d %PROJECT_ROOT%\auth-service && java -jar target\auth-service-1.0.0.jar"

echo.
echo 服务已启动，请检查日志确认Nacos地址配置是否生效
echo.
echo 按任意键退出...
pause >nul